/**
 * Created by MingIr on 2017/9/28.
 */
import { common } from './common';

/**
 * 查找箱子
 * @param that
 * @param timer
 * @constructor
 */
const Finding = (that) => {
    if(that.location) {
        clearInterval(that.timer);
        common.post(common.api.bag.find, {
            longitude: that.location.longitude,
            latitude: that.location.latitude
        }).then(res => {
            that.setState({
                packet: true,
                bagInfo: res
            });
        }).catch(err => {
            that.timer = setInterval(function(){
                Finding(that);
            },5000);
        });
    }
}

export default {
    finding : Finding
}